#include <bits/stdc++.h>
using namespace std;
bool isdig(char c){return '0' <=c && c <= '9';} 
const int N = 1e5 + 5;
const int M = 5005;
typedef long long ll; 
ll read(){
    ll x = 0 , f = 1;
    char c = getchar();
    while (!isdig(c)){
        if (c == '-') f = -1;
        c = getchar();
    }
    while (isdig(c)){
        x = (x << 3) + (x << 1) + c - '0';
        c = getchar();
    }
    return x * f;
}
void write(ll x){
    if (x < 0){
        x = -x;
        putchar('-');
    }
    if (x >= 10) write(x / 10);
    putchar(x % 10 + '0');
}
struct Cars{
    ll d , v_squ , a;
    ll l , r;
    void Get(){
        d = read();
        v_squ = read();
        a = read();
        v_squ = v_squ * v_squ;
    }
    ll speed(ll pl){
        ll now = v_squ + 2 * a * (pl - d);
        return now;
    }
    void cal(ll V_squ){
        
    }
    bool operator < (const Cars & A) const{
        return d < A.d;
    }
}a[N];
ll b[N],vis[N];
bool chk[N];
void solve1(ll n , ll m , ll V_squ , ll L){
    ll ans = 0;
    for (int i = 1 ; i <= n ;i ++){
        if (a[i].v_squ > V_squ && a[i].d <= b[m]) ans ++;
    }
    write(ans);
    putchar(' ');
    write(m - (ans != 0));
    putchar('\n');
}
void solve2(ll n , ll m , ll V_squ , ll L){
    ll ans1 = 0;
    for (int i = 1 ; i <= n ;i ++){
        if (a[i].d > b[m]) continue;
        if (a[i].speed(b[m]) > V_squ) ans1 ++;
    }
    write(ans1);
    putchar(' ');
    write(m - (ans1 != 0));
    putchar('\n');
}
void solve3(ll n , ll m , ll V_squ , ll L){

}
bool pd[N];
void solve4(ll n , ll m , ll V_squ , ll L){
    for (int i = 1 ; i <= n ;i ++) pd[i] = false;
    for (int i = 1 ; i <= m ; i ++){
        for (int j = 1 ; j <= n ; j ++){
            if (a[j].d > b[i]) continue;
            if (a[j].speed(b[i]) > V_squ) pd[j] = 1;
        }
    }
    ll ans = 0ll;
    for (int i = 1 ; i <= n ; i ++) ans += pd[i];
    write(ans);
    putchar(' ');
    ll sum = 0ll , getans = m;
    for (int i = 0 ; i < (1 << m) ; i ++){
        ll cnt = 0ll;
        ll s = 0ll;
        for (int j = 1 ; j <= n ;j ++) pd[j] = false;
        for (int j = 1 ; j <= m ; j ++){
            if (i & (1 << (j - 1))){
                cnt ++;
                for (int k = 1 ; k <= n ;k ++){
                    if (a[k].d > b[j]) continue;
                    if (a[k].speed(b[j]) > V_squ) pd[k] = 1;
                }
            }
        }
        for (int j = 1 ; j <= n ; j ++) s += pd[j];
        if (s == ans) getans = min(getans , cnt);
    }
    write(m - getans);
    putchar('\n');
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out" , "w",stdout);
    ll T = read();
    while (T --) {
        ll n = read() , m = read() , L = read() , V_squ = read();
        V_squ = V_squ * V_squ;
        for (int i = 1 ; i <= m ; i ++) chk[i] = vis[i] = b[i] = 0ll;
        for (int i = 1 ; i <= n ; i ++){
            a[i].Get();
        }
        for (int i = 1 ; i <= m ;i ++) b[i] = read();
        if (m <= 20) solve4 (n , m , V_squ , L);
        ll cnt1 = 0 , cnt2 = 0,cnt3 = 0;
        for (int i = 1 ; i <= n ;i ++){
            if (a[i].a < 0) cnt1 ++;
            if (a[i].a > 0) cnt2 ++;
            if (a[i].a == 0) cnt3 ++ ;
        }
        if (cnt3 == n) solve1(n , m , V_squ , L);
        if (cnt2 == n) solve2(n , m , V_squ , L);
        if (cnt1 == n) solve3(n , m , V_squ , L);
    }
    return 0;
}